//
//  AboutMeViewController.m
//  51易借
//
//  Created by 张睿 on 2017/8/28.
//  Copyright © 2017年 张睿. All rights reserved.
//

#import "AboutMeViewController.h"

@interface AboutMeViewController ()

@property (nonatomic, weak)UIView * topView;
@property (nonatomic, weak)UIView * inputView;
@property (nonatomic, weak)UILabel * aboutMeLabel;

@end

@implementation AboutMeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = BACK_COLOR;
    
    [self setupNavBar];
    [self setupUI];
}


- (void)setupNavBar{
    
    self.title = @"关于我们";
    
    UIButton * backButton = [[UIButton alloc] init];
    
    backButton.frame = CGRectMake(15 * SCREENH6, 5 * SCREENH6, 12 * SCREENH6, 20 * SCREENH6);
    [backButton setImage:[UIImage imageNamed:@"箭头"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(backToLastView) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem * leftButton = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    
    self.navigationItem.leftBarButtonItem = leftButton;
}


- (void)setupUI{
    
    UIView * topView = [UIView new];
    
    topView.backgroundColor = TOTAL_COLOR;
    
    self.topView = topView;
    
    [self.view addSubview:self.topView];
    
    
    UIView * inputView = [UIView new];
    
    inputView.backgroundColor = [UIColor whiteColor];
    
    self.inputView = inputView;
    
    [self.view addSubview:self.inputView];
    
    
    UILabel * aboutMeLabel = [UILabel new];
    
    aboutMeLabel.textColor = [UIColor blackColor];
    aboutMeLabel.font = [UIFont systemFontOfSize:13.5 * SCREENH6];
    aboutMeLabel.numberOfLines = 0;
    aboutMeLabel.text = @"     上海51易借互联网金融信息服务有限公司（以下简称“51易借”）成立于2014年，系51易借下成员，依托强大的集团支持和管理团队，结合自身金融专业能力和互联网技术应用，致力于互联网金融服务领域的精耕细作。";
    aboutMeLabel.lineBreakMode = NSLineBreakByCharWrapping;
    
    //设置字间距
    
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:aboutMeLabel.text];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    [paragraphStyle setLineSpacing:4 * SCREENH6];
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [aboutMeLabel.text length])];
    [aboutMeLabel setAttributedText:attributedString];
    [aboutMeLabel sizeToFit];
    
    self.aboutMeLabel = aboutMeLabel;
    
    [self.inputView addSubview:self.aboutMeLabel];
}


- (void)viewDidLayoutSubviews{
    
    [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.trailing.mas_equalTo(self.view);
        make.height.mas_equalTo(64 * SCREENH6);
    }];
    
    [self.inputView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.mas_equalTo(self.view);
        make.top.mas_equalTo(self.topView.mas_bottom);
        make.height.mas_equalTo(114 * SCREENH6);
    }];
    
    [self.aboutMeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.inputView).offset(10 * SCREENH6);
        make.top.mas_equalTo(self.inputView).offset(15 * SCREENH6);
        make.trailing.mas_equalTo(self.inputView).offset(-10 * SCREENH6);
    }];
}


- (void)backToLastView{
    
    [self.navigationController popViewControllerAnimated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
